package com.ncmmall.application.business.aboutus;

import com.ncmmall.domain.business.aboutus.AboutUs;
import com.ncmmall.domain.business.aboutus.AboutUsRepository;
import com.ncmmall.querychannel.service.QueryChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;

/**
 * 关于我们
 *
 * @author likaikai
 * @date 2019-07-11 10:33
 */
@Service
@Transactional
public class AboutUsApplication {

    @Autowired
    private AboutUsRepository aboutUsRepository;

    @Autowired
    private QueryChannelService queryChannelService;

    /**
     * 修改关于我们
     *
     * @param param
     */
    public void modify(AboutUs param) {
        AboutUs aboutUs = queryChannelService.queryOneEntity("select * from mall_about_us limit 1", Collections.emptyMap(), AboutUs.class);
        if (aboutUs == null) {
            aboutUs = new AboutUs();
        }
        aboutUs.setContent(param.getContent());
        aboutUsRepository.save(aboutUs);
    }
}
